package com.shitou.web;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.shitou.pojo.Milestone;
import com.shitou.pojo.Project;
import com.shitou.pojo.User;
import com.shitou.service.MilestoneService;
import com.shitou.service.ProjectService;

@Results({@Result(name=BaseAction.RELOAD,location="milestone.jspx",params={"id","${id}"},type="redirectAction")})
public class MilestoneAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	
	@Resource
	private ProjectService projectService;
	private Project project;
	private int projectid;
	@Resource
	private MilestoneService milestoneService;
	private Milestone milestone;
	private Integer id;

	@Override
	public String del() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String input() throws Exception {
		project = projectService.findById(projectid);
		return INPUT;
	}

	@Override
	public String list() throws Exception {
		milestone = milestoneService.findById(id);
		return SUCCESS;
	}

	@Override
	public String save() throws Exception {
		project = projectService.findById(projectid);
		id = milestoneService.save(milestone, project, (User)getSessionAttribute("user"));
		return RELOAD;
	}

	//getter and setter
	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public int getProjectid() {
		return projectid;
	}

	public void setProjectid(int projectid) {
		this.projectid = projectid;
	}

	public Milestone getMilestone() {
		return milestone;
	}

	public void setMilestone(Milestone milestone) {
		this.milestone = milestone;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	
}
